package de.haw.HES.Vertrieb;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

import de.haw.HES.Kundenmanagement.Kunde;
import de.haw.HES.base.FachObjekt;

@Entity
@Table(name="angebot")
public class Angebot implements FachObjekt {

	private int id;
	private Date gueltigAb;
	private Date gueltigBis;
	private double gesamtpreis;
	private List<Menge> menge = new ArrayList<Menge>();
	private Kunde kunde;
	
	@Id
	@GenericGenerator(name = "generator", strategy = "increment")
    @GeneratedValue(generator = "generator")
	@Column(name="angebot_id")
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public Date getGueltigAb() {
		return gueltigAb;
	}
	public void setGueltigAb(Date gueltigAb) {
		this.gueltigAb = gueltigAb;
	}
	public Date getGueltigBis() {
		return gueltigBis;
	}
	public void setGueltigBis(Date gueltigBis) {
		this.gueltigBis = gueltigBis;
	}
	public double getGesamtpreis() {
		return gesamtpreis;
	}
	public void setGesamtpreis(double gesamtpreis) {
		this.gesamtpreis = gesamtpreis;
	}
	
	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY,mappedBy="pk.angebot")
	public List<Menge> getMenge() {
		return menge;
	}
	public void setMenge(List<Menge> menge) {
		this.menge = menge;
	}
	
	@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
	@JoinColumn(name="kunde_fk")
	public Kunde getKunde() {
		return kunde;
	}
	public void setKunde(Kunde kunde) {
		this.kunde = kunde;
	}
	
	
	
}
